package edu.ntu.cloudroid.model;

import com.sun.xacml.combine.PolicyCombiningAlgorithm;

import edu.ntu.cloudroid.model.function.similar.ISimilarFunc;
import edu.ntu.cloudroid.model.function.stats.IDataStats;
import edu.ntu.cloudroid.xacml.obligation.ObligationHandle;

public class IDs {
	String OBLIGATION = "urn:cloudroid:obligation:";
	
	public static enum ObligationID {
		DefaultObligation, FilteringObligation, GranularityObligation, 
		SimilarityObligation, SlidingWindowObligation, StatsObligation, NoObligation
	}
	
	public static enum DataID {
		LocationData, VitalSignData, TraceData
	}
	

	public static enum PolicyID {
		SimpleFiltering, SimpleGranularity, SimpleSimilarity, SimpleSlidingWindow, SimpleStats
	}

	public static enum UploadID {
		Profile, Policy, Friend, Group, Data, MetaData, Log
	}

	// for statistics function
	public static enum StatFunctionID {
		MostFrequentLocFunction, CountFunction, MaxFunction, MinFunction, AverageFunction
	}

	public static enum SimilarityFunctionID {
		LocationSimilar, VitalSignSimilar
	}

	public static enum PolicyCombiningAlgID {
		ClouDroidPolicyCombiningAlgorithm
	}

	public static PolicyCombiningAlgorithm getPolicyCombiningAlgorithm(int id) throws Exception{
		Class cl = Class.forName("edu.ntu.cloudroid.xacml.combining."
				+ IDs.PolicyCombiningAlgID.values()[id].name());
		return (PolicyCombiningAlgorithm)cl.newInstance();
	}

	public static IDataStats getStatsFunction(int id) throws Exception {
		Class cl = Class.forName("edu.ntu.cloudroid.model.function.stats."
				+ IDs.StatFunctionID.values()[id].name());
		return (IDataStats) cl.newInstance();
	}

	public static ISimilarFunc getSimilarityFunction(int id) throws Exception {
		Class cl = Class.forName("edu.ntu.cloudroid.model.function.similar."
				+ IDs.SimilarityFunctionID.values()[id].name());
		return (ISimilarFunc) cl.newInstance();
	}
		
	public static ObligationHandle getObligationHandle(String ob) throws Exception{
		Class cls = Class.forName("edu.ntu.cloudroid.xacml.obligation."
				+ IDs.ObligationID.valueOf(ob));
		return (ObligationHandle)cls.newInstance();
	}
}
